;
; Copyright (c) Microsoft Corporation.  All rights reserved.
;
;
; Use of this sample source code is subject to the terms of the Microsoft
; license agreement under which you licensed this sample source code. If
; you did not accept the terms of the license agreement, you are not
; authorized to use this sample source code. For the terms of the license,
; please see the license agreement between you and Microsoft or, if applicable,
; see the LICENSE.RTF on your install media or the root of your tools installation.
; THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
;
;
; (C) Copyright 2006 Marvell International Ltd.
; All Rights Reserved
;
; Copyright (c) 1998, 1999 ARM Limited
; All Rights Reserved
;

    OPT     2       ; disable listing
    INCLUDE kxarm.h
    OPT     1       ; reenable listing
    OPT     128     ; disable listing of macro expansions
    INCLUDE armmacros.s

    TEXTAREA


    LEAF_ENTRY	xscale_l2_cache_fetch_and_lock
       bic     r0, r0, #0x20 - 1
L2FLockLoop
       mcr     p15, 1, r0, c9, c5, 0  
       cmp    r0, r1                  
       add     r0, r0, #0x20
       bls      L2FLockLoop
;dead_loop
 ;      bl dead_loop
    
    RETURN



    LEAF_ENTRY	xscale_l2_cache_allocate_and_lock

       tst     r0, #0x20 - 1
       mcrne   p15, 1, r0, c9, c5, 0   
       addne   r0, r0, #0x20
       bic     r0, r0, #0x20 - 1
       tst     r1, #0x20 - 1
       mcrne   p15, 1, r1, c9, c5, 0   
       subne   r1, r1, #0x20
L2ALockLoop
       mcr     p15, 1, r0, c9, c5, 2   
       cmp     r0, r1                  
       add     r0, r0, #0x20  
       bls     L2ALockLoop
    
    RETURN
    

  LEAF_ENTRY	xscale_l2_cache_unlock_range
  	bic     r0, r0, #0x20 - 1
L2UnLockLoop
        mcr     p15, 1, r0, c7, c11, 1  
       mcr     p15, 0, r0, c7, c10, 5  
        mcr     p15, 1, r0, c7, c7, 1   
        cmp     r0, r1                 
        add     r0, r0, #0x20
        bls     L2UnLockLoop
  
    
    RETURN

 LEAF_ENTRY	xscale_l2_cache_unlock_all
  	MCR p15, 1, R0, c9, c5, 1
  
    
    RETURN
    

  
    

       
;------------------------------------------------------------------------------       
    END
